package 力扣刷题.探索初级算法.数组.两个数组的交集2;

import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;
//未完成，题没看懂
public class Solution {
    public static void main(String[] args) {


        Scanner s=new Scanner(System.in);
        int len1=s.nextInt();
        int[] nums1=new int[len1];
        for (int i = 0; i < len1; i++) {
            nums1[i]=s.nextInt();
        }
        int len2=s.nextInt();
        int[] nums2=new int[len2];
        for (int i = 0; i < len2; i++) {
            nums2[i]=s.nextInt();
        }
        System.out.println(Arrays.toString(new Solution().intersect(nums1, nums2)));
    }
    public int[] intersect(int[] nums1, int[] nums2) {
        int[] shortNums,longNums;
        if(nums1.length<nums2.length) {
            shortNums=nums1;
            longNums=nums2;
        }
        else {
            shortNums=nums2;
            longNums=nums1;
        }
        Vector<Integer> intersectNums=new Vector<>();
        for (int i = 0; i < longNums.length; i++) {
            for (int j = 0; j <shortNums.length; j++) {
                if(shortNums[j]==longNums[i]) {
                    intersectNums.add(shortNums[j]);
                }
            }
        }
        return null;
    }
}
